/*
 *
 *  * Copyright (c) 2016. For Intelligent Group.
 *
 */

package com.intelligent.ispc.client.core.view.global;

import com.intelligent.ispc.client.utils.ApplicationBeanUtils;
import com.intelligent.ispc.client.utils.GBC;

import javax.annotation.PostConstruct;
import javax.swing.*;
import java.awt.*;

/**
 * Created by Peter on 2016/7/13.
 */
@org.springframework.stereotype.Component
public class MainContentPanel extends JPanel {
    /**
     * Constructor
     */
    public MainContentPanel() {
    }

    /**
     * Initialize components
     */
    @PostConstruct
    public void initComponents() {
        this.setBackground(Color.WHITE);
        this.setLayout(new GridBagLayout());
        this.add(getDefaultPanel(), new GBC(0, 0).setFill(GBC.BOTH).setWeight(100, 100));
    }

    public void defaultPanel() {
        this.removeAll();
        this.add(getDefaultPanel(), new GBC(0, 0).setFill(GBC.BOTH).setWeight(100, 100));
        this.validate();
        this.repaint();
    }

    public void changePanel(Class panel) {
        this.removeAll();
        this.add((JPanel) ApplicationBeanUtils.getBean(panel), new GBC(0, 0).setFill(GBC.BOTH).setWeight(100, 100));
        this.validate();
        this.repaint();
    }

    private JPanel getDefaultPanel() {
        JPanel defaultPanel = new JPanel();
        defaultPanel.add(new JLabel("Welcome to iSPC."));
        return defaultPanel;
    }
}
